using System.Collections.Generic;
using System.Linq;
using FishFillets.Model.GameItems;

namespace FishFillets.Model
{
    /// <summary>
    /// Class representing single game level.
    /// </summary>
    public class Level
    {
        /// <summary>
        /// Unique ID of this level.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Width of this level.
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// Height of this level.
        /// </summary>
        public int Height { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Fish Small { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Fish Big { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<Item> Items { get; set; }

        /// <summary>
        /// Number of restart of this level.
        /// Note it's counted from zero each time level is opened from game map.
        /// </summary>
        public int RestartCount;

        #region ----- virtual properties ---------------------------------

        public List<BaseItem> AllItems
        {
            get { return allItems ?? (allItems = Items.OfType<BaseItem>().Concat(new[] { Big, Small }).ToList()); }
        }
        private List<BaseItem> allItems;

        public Dictionary<string, Item> ItemsDict
        {
            get { return itemsDict ?? (itemsDict = Items.ToDictionary(i => i.AssetName)); }
        }
        private Dictionary<string, Item> itemsDict;

        #endregion
    }
}
